#include "widget.h"
#include "ui_widget.h"
#include <QPushButton>
#include <QDebug>
#include <QFileDialog>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    QPushButton* button = new QPushButton("查看文件属性", this);
    connect(button, &QPushButton::clicked, [=](){
       QString path = QFileDialog::getOpenFileName(this);
       QFileInfo fileInfo(path); // 构造对象
       // 打印相关属性
       qDebug() << fileInfo.fileName();
       qDebug() << fileInfo.suffix();
       qDebug() << fileInfo.path();
       qDebug() << fileInfo.size();
       qDebug() << fileInfo.isFile();
       qDebug() << fileInfo.isDir();
       // ...
    });
}

Widget::~Widget()
{
    delete ui;
}

